package com.caigou.modules.query.widget

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.Gravity
import android.view.Window
import android.view.WindowManager
import android.widget.Button
import android.widget.EditText
import android.widget.ImageView
import com.caigou.comm.base.ext.getScreenWidth
import com.caigou.modules.query.R

/**
 * @author #Suyghur.
 * Created on 2021/12/14
 */
class CountDialog(context: Context) : Dialog(context) {

    private lateinit var ivClose: ImageView
    lateinit var etNum: EditText
    lateinit var btnConfirm: Button

    init {
        setCanceledOnTouchOutside(true)
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        initView(context)
    }

    private fun initView(context: Context) {
        setContentView(R.layout.query_count_dialog)
        val attr = window?.attributes as WindowManager.LayoutParams
        //设置dialog在布局中的位置
        attr.gravity = Gravity.CENTER
        attr.width = getScreenWidth(context)

        ivClose = findViewById(R.id.query_count_dialog_iv_close)
        ivClose.setOnClickListener {
            dismiss()
        }

        etNum = findViewById(R.id.query_count_dialog_et_num)
        btnConfirm = findViewById(R.id.query_count_dialog_btn_confirm)
    }

}

